package hu.kisprof.quiz.view.panels;

import hu.kisprof.quiz.view.Labels;
import hu.kisprof.quiz.view.QuizGUI;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.LineBorder;

public class QuizEndGamePanel extends JPanel implements ActionListener{

	private static final long serialVersionUID = 6142807535837368063L;
	private QuizGUI gui;
	private JButton okButton;
	
	public QuizEndGamePanel(QuizGUI gui,JPanel p1panel,JPanel p2panel){
		super(new BorderLayout());
		this.gui =gui;
		okButton = new JButton(Labels.ok);
		okButton.addActionListener(this);
		
		JPanel tmpPanel= new JPanel(new GridLayout(1,2));
			tmpPanel.add(p1panel);
			tmpPanel.add(p2panel);
		this.add(tmpPanel,BorderLayout.NORTH);
		
		
		JPanel tmp2Panel = new JPanel(new BorderLayout());
			tmpPanel = new JPanel(new GridLayout(1,4));
			tmpPanel.setBorder(new LineBorder(Color.BLACK));
			tmpPanel.add(new JLabel(Labels.yourPoints+":"));
			tmpPanel.add(new JLabel(gui.getControl().getPoints(gui.getControl().getPlayer().getUsername())+""));
			tmpPanel.add(new JLabel(Labels.enemyPoints+":"));
			tmpPanel.add(new JLabel(gui.getControl().getPoints(gui.getControl().getInGameEnemy())+""));
		tmp2Panel.add(tmpPanel,BorderLayout.CENTER);
		
			tmpPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
			tmpPanel.add(okButton);
		tmp2Panel.add(tmpPanel,BorderLayout.SOUTH);
		
		this.add(tmp2Panel,BorderLayout.SOUTH);
		
		
		
		
	}
	
	
	@Override
	public void actionPerformed(ActionEvent e) {
		if(e.getActionCommand().equals(Labels.ok)){
			gui.setActualContent(new QuizRoomPanel(gui.getControl().getCurrentRoom(),gui));
			gui.getControl().setInGame(false);
		}
		
	}

}
